﻿Partial Class Document

    Public Class Row
        Public Table As Document.Table
        Dim Cells As New List(Of Cell)
        Dim IsHeader As Boolean

        Sub New(ByVal Table As Document.Table, Optional ByVal IsHeader As Boolean = False)
            Me.Table = Table
            Me.IsHeader = IsHeader
        End Sub

        Sub SetValues(ByVal ParamArray Params() As Object)
            Dim Column As Integer = 0
            For i As Integer = 0 To Params.Length - 1
                Dim Cell As New Cell(Me, Params(i), Table.Columns(Column), IsHeader)
                Cells.Add(Cell)
                Column += Cell.ColSpan
            Next
        End Sub

        Sub Print(ByVal Info As PrintInfo)
            Dim MaxHeight As Integer = 0
            For Each Cell As Cell In Cells
                Dim Size As SizeF = Cell.Measure(Info)
                If Size.Height > MaxHeight Then MaxHeight = Size.Height
            Next
            If Info.Reserve(MaxHeight) Then
                Table.Section.Header.Print(Info)
                If Not Table.HeaderRow Is Nothing Then Table.HeaderRow.Print(Info)
            End If
            For Each Cell As Cell In Cells
                Cell.Print(Info, MaxHeight)
            Next
            Info.Progress(MaxHeight)
        End Sub

    End Class

End Class
